Repository navigation
Add OpenAPI 3.2 support with webhooks and enhanced components - #6
Merged
Merged
Conversation
fix: simplify utoipa-gen feature gates to fix jiff_0_2 Enabling the "jiff_0_2" feature on its own would not correctly enable the more elaborate is_primitive branch because it was mistakenly omitted from the feature gate list. Rather than merely fixing the feature gate list, this commit simplifies the logic to make such a mistake impossible in the future.
* fix: workaround time/cookie incompatibility * Also fix examples
juhaku#1580) * Fix stack overflow * fix: emit vec![] instead of array literals to avoid large stack arrays Wide structs/enums generated huge `[..]` array literals in ToSchema/IntoParams, tripping clippy::large_stack_arrays and overflowing the stack. Make the Array tokenizer emit vec![] and deny the lint so it doesn't regress again (juhaku#1454). * chore: not really testing so just smoke test --------- Co-authored-by: Rafał Mikrut <mikrutrafal@protonmail.com> Co-authored-by: Jaye Park <jaye.park@helsing.ai>
* Add OpenAPI 3.2 support * Fix OpenAPI 3.2 CI failures * ci: re-trigger build after upstream time 0.3.48 yank The 2026-06-12 CI run resolved time 0.3.48 (the repo intentionally does not commit a root Cargo.lock, so CI takes the latest deps). time 0.3.48 shipped an E0119 trait-coherence regression that broke the cookie crate, failing the utoipa-gen and examples jobs (and cancelling utoipa via fail-fast). time 0.3.48 has since been yanked and 0.3.49 published. This empty commit re-runs CI to pick up the fixed resolution; verified locally that the full utoipa-gen matrix and example compilation pass with time 0.3.49. * Address review feedback on OpenAPI 3.2 support - Keep `Version31` as the default OpenApiVersion; `Version32` is now opt-in (no deprecation). Reverts the default-output version back to 3.1.0 so the change is non-breaking until 3.2 tooling support is widespread. - Add `OpenApiBuilder::openapi(..)` so 3.2 output can be opted into. - Rename `self_url` field/builder to `self_uri` to match the spec wording. - Simplify `OpenApiVersion` deserialize with slice `matches!` patterns. - Drop redundant non-empty check when merging `additional_operations`. - Use `RefOr::T(parameter.into())` instead of the double `.into().into()`. - Tidy `HttpBuilder::deprecated` formatting. - Revert the actix `#[utoipa::path]` doc examples from `rust,ignore` back to `rust` (they pass under the `actix_extras` feature CI runs).
* docs: add examples and changelog * test: fix empty description being omitted * chore: change parameters to refs
* add example for IntoParams with generic argument * add automated test * working example of generic params it breaks everything else which is a bummer * fix implementation with into_params * update unit tests to pin behavior * minor code cleaning * remove example code I assume a reviewer might call this superfluous. This code was useful for testing locally. * shorten code * fix warning * add basic changelog
…ypes (juhaku#1592) * feat(gen): support item_schema attribute for streaming/SSE response types * chore: update sse example to use programmatic openapi 3.2 version mapping * chore: use openapi version attribute As juhaku#1591 is merged, I can remove `api.openapi = utoipa::openapi::OpenApiVersion::Version32;` from the example to replace with `#[openapi(version = "3.2.0", components(schemas(PetEvent)))]`.
* Recursively discover flattened fields in maps This allows the discovered fields to appear in component.schemas without having to explicitly list it as a workaround. Fixes juhaku#1330 * Use assert_value * Apply suggestion from @CommanderStorm Co-authored-by: Frank Elsinga <frank@elsinga.de> --------- Co-authored-by: Frank Elsinga <frank@elsinga.de>
Updated documentation comments to remove commented-out code.
Add the following entry in utoipa-gen/CHANGELOG.md * Recursively discover flattened fields in maps for `#[serde(flatten)]`. (juhaku#1582)
The test was commented out as failing to compile. It was missing imports, and the justfile did not enable `utoipa/auto_into_responses`, which gates the `IntoResponses` impl for `Result<T, E>`.
…uhaku#1619) This commit removes support for expression style ignore attribute from `ToSchema` and `IntoParams` macro. This is to fix issue where ignore sometimes did not ignore values, because it was evaluated in runtime and function reference ignore can be evaluated only during runtime but we need to evaluate this at build time thus removing the possibility to define function reference as ignore attribute value. ## Breaking Following syntax demonstrates what was allowed before, but will be not available in new version 6. ```rust // before allowed fn ignore_always() -> bool { true } #[derive(ToSchema)] struct Value { #[schema(ignore = ignore_always)] field: String } ```
This bug has been around since `utoipa-gen 5.1.3` where the `#[schema(min_properties=...)]` gets generated as `max_properties` attribute. Closes juhaku#1622
Utoipa-swagger-ui build failed to build with `cache` feature on because sha2 crate had updated its `generic-array` to `hybrid-array` dependency breaking the existing implementation hex formatting. More details here: RustCrypto/hybrid-array#201
Fix unsigned integers know format serialization. They used falsely `kebab-case` instead of `lowercase`. Now type like `UInt16` will render `uint16` instead of `u-int16`. --------- Co-authored-by: Juha Kukkonen <juha7kukkonen@gmail.com>
Implements rust expression support for `names` and `title` attributes:
```rust
const STRUCT_TITLE: &str = "Post Title";
let schema = api_doc! {
#[schema(title = STRUCT_TITLE)]
struct Post {
id: i64,
description: String,
}
};
const NEW_NAME: &str = "renamed_field";
#[derive(IntoParams)]
#[into_params(parameter_in = Path, names(NEW_NAME))]
struct Filter(
#[allow(unused)]
(),
);
```
---------
Co-authored-by: Juha Kukkonen <juha7kukkonen@gmail.com>
…u#1625) Add missing snapshots for `utoipa-gen` test using newly supported expression in title and name. ```rust const NEW_NAME: &str = "renamed_field"; #[derive(IntoParams)] #[into_params(parameter_in = Path, names(NEW_NAME))] struct Filter(()); ``` --------- Co-authored-by: juhaku <26358664+juhaku@users.noreply.github.com>
Serde only treats a missing Option field as None when the field has no deserialize_with or with attribute. With one of those and no default, a missing field is an error, so ToSchema and IntoParams should list the field as required. It stays nullable.
Add support for `merge` in `OpenApi` derive Keep nest and merge as separate derive attributes, but parse their common api and tags arguments through OpenApiReference. List merge in the unexpected-attribute diagnostic and cover merge precedence in tests. --------- Co-authored-by: Martin Moreira de Jesus <martin.moreira-de-jesus@protonmail.com>
Brings in 26 upstream commits (OpenAPI 3.2 support, syn 3, generic IntoParams, `merge` in OpenApi derive, expr titles/names, several schema fixes) on top of the fork's tagged_discriminator and IntoParams flatten features. - keep meteroid-* package names, bump to upstream versions (utoipa/gen 6.0.0, config 0.1.3, axum 0.3.0, scalar 0.4.0) - combine IntoParams flatten support with upstream generic schemas - adjust new upstream snapshot for the fork's crate description - update RELEASING.md versions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds comprehensive support for OpenAPI 3.2 specification, including new features like webhooks, enhanced component definitions, and improved schema handling. It also introduces the ability to merge multiple OpenAPI documents and opt-in to OpenAPI 3.2 output.
Key Changes
OpenAPI 3.2 Support
OpenApiVersionenum withVersion31(default) andVersion32variantsopenapi(version = "3.2.0")derive attribute to opt-in to OpenAPI 3.2 outputwebhooks: For describing incoming requests initiated by the API providerjson_schema_dialect: Default JSON Schema dialect for Schema Objects$self(self_uri): URI identifying the OpenAPI document for resolving relative referencesEnhanced Components
Componentsstruct with new reusable component maps:parameters: Reusable parameter definitionsexamples: Reusable example objectsrequest_bodies: Reusable request body definitionsheaders: Reusable header definitionslinks: Reusable link definitionscallbacks: Reusable callback definitionspath_items: Reusable path item definitionsmedia_types: Reusable media type objectssecurity_schemesto useRefOr<SecurityScheme>for better flexibilityOpenAPI Merging
merge(...)attribute to#[derive(OpenApi)]for combining multiple OpenAPI documentsnest(...)andmerge(...)for different composition strategiesSecurity Scheme Improvements
deprecatedfield toMutualTlsvariantdeprecatedfield toApiKeyValuestructPath and Schema Enhancements
$refsupport toPathItemfor referencing other path itemsCallbacktype alias for callback expressions mapping to path itemssummaryfield toResponseobjectitemSchemasupport inContentfor streaming media types (SSE, JSONL, etc.)Code Generation Improvements
titleandnamesattributes in derive macrosdeserialize_withattribute handlingNew Example
openapi-3_2-sseexample demonstrating Server-Sent Events documentation using OpenAPI 3.2's streaming media type supportBuilder API Enhancements
OpenApiBuilder::openapi()method to set OpenAPI versionOpenApiBuilder::webhooks()method for webhook definitionsOpenApiBuilder::json_schema_dialect()methodOpenApiBuilder::self_uri()methodNotable Implementation Details
Pathsstructure as regular pathsskip_serializing_ifto keep output cleanhttps://claude.ai/code/session_01PvYxH9Xj7KQZCeSF2F81RT